package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Paperproject;
import com.hbnu.system.service.IPaperprojectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/paperproject")
@Api(tags = "论文关联项目模块")
public class PaperprojectController {
    @Autowired IPaperprojectService iPaperprojectService;

    @ApiOperation("论文关联项目添加")
    @PostMapping("/AddPaperProject")
    public Rest<Boolean> AddPaperProject(@RequestBody Paperproject paperproject){
        boolean add = iPaperprojectService.addPaperProject(paperproject);
        return add ? Rest.success() : Rest.failed();
    }

    @ApiOperation("论文关联项目删除")
    @GetMapping("/RemovePaperProject")
    public Rest<Boolean> RemovePaperProject(String paperProjectID){
        boolean remove = iPaperprojectService.removePaperProject(paperProjectID);
        return remove ? Rest.success() : Rest.failed();
    }

    @ApiOperation("论文关联项目更新")
    @PostMapping("/UpdatePaperProject")
    public Rest<Boolean> UpdatePaperProject(@RequestBody Paperproject paperproject){
        boolean update = iPaperprojectService.updatePaperProject(paperproject);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("论文关联项目查询")
    @GetMapping("/GetPaperProjectByPaperID")
    public Rest<List<Paperproject>> GetPaperProjectByPaperID(String paperID){
        List<Paperproject> paperProjectByPaperID = iPaperprojectService.getPaperProjectByPaperID(paperID);
        return Rest.success(paperProjectByPaperID);
    }


}

